class Operando:
  def __init__(self):
    pass

class Cte(Operando):
  def __init__(self,v):
    self.v= v

  def __str__(self):
    return `self.v`

class MD(Operando):
  def __init__(self,d):
    self.d=d

  def __str__(self):
    return "&%d" % self.d

class MI1(Operando):
  def __init__(self,e,d):
    self.e=e
    self.d=d

  def __str__(self):
    return "%d[&%d]" % (self.e,self.d)

class MI2(Operando):
  def __init__(self,d1,d2):
    self.d1=d1
    self.d2=d2

  def __str__(self):
    return "&%d[&%d]" % (self.d1,self.d2)

class STAN:
  def __init__(self,cod,op1,op2,et,coment):
    self.cod= cod
    self.op1= op1
    self.op2= op2
    self.et= et
    self.coment= coment

  def __str__(self):
    if self.et:
      s="%s:" % self.et
    else:
      s=""
    if self.cod:
      if self.cod=="=":
        s=s+"\t%s = %s" % (self.op1,self.op2)
      else:
        s=s+"\t"+self.cod
        if self.op1:
          s=s+" %s" % self.op1
          if self.op2:
            s=s+" %s" % self.op2
    if self.coment:
      if s:
        s= s+"\t# %s" % self.coment
      else:
        s= "# %s" % self.coment
    return s

def Comentario(cadena):
  return STAN(None,None,None,None,cadena)

def Etiqueta(et, coment=None):
  return STAN(None,None,None,et,coment)

def Asignacion(dest,fuente,coment=None,et=None):
  return STAN("=",dest,fuente,et,coment)

def PUSH(fuente,coment=None,et=None):
  return STAN("PUSH",fuente,None,et,coment)

def FPUSH(fuente,coment=None,et=None):
  return STAN("FPUSH",fuente,None,et,coment)

def POP(dest=None,coment=None,et=None):
  return STAN("POP",dest,None,et,coment)

def FPOP(dest=None,coment=None,et=None):
  return STAN("FPOP",dest,None,et,coment)

def DUP(coment=None,et=None):
  return STAN("DUP",None,None,et,coment)

def FDUP(coment=None,et=None):
  return STAN("FDUP",None,None,et,coment)

def SWAP(coment=None,et=None):
  return STAN("SWAP",None,None,et,coment)

def FSWAP(coment=None,et=None):
  return STAN("FSWAP",None,None,et,coment)

def INC(dir= None, coment=None,et=None):
  return STAN("INC",dir,None,et,coment)

def DEC(dir= None, coment=None,et=None):
  return STAN("DEC",dir,None,et,coment)

def ADD(coment=None,et=None):
  return STAN("ADD",None,None,et,coment)

def SUB(coment=None,et=None):
  return STAN("SUB",None,None,et,coment)

def MUL(coment=None,et=None):
  return STAN("MUL",None,None,et,coment)

def DIV(coment=None,et=None):
  return STAN("DIV",None,None,et,coment)

def MOD(coment=None,et=None):
  return STAN("MOD",None,None,et,coment)

def MOD(coment=None,et=None):
  return STAN("MOD",None,None,et,coment)

def NEG(coment=None,et=None):
  return STAN("NEG",None,None,et,coment)

def FADD(coment=None,et=None):
  return STAN("FADD",None,None,et,coment)

def FSUB(coment=None,et=None):
  return STAN("FSUB",None,None,et,coment)

def FMUL(coment=None,et=None):
  return STAN("FMUL",None,None,et,coment)

def FDIV(coment=None,et=None):
  return STAN("FDIV",None,None,et,coment)

def TOFLOAT(coment=None,et=None):
  return STAN("TOFLOAT",None,None,et,coment)

def TOINT(coment=None,et=None):
  return STAN("TOINT",None,None,et,coment)

def Comparacion(comp,coment=None,et=None):
  return STAN(comp,None,None,et,coment)

def IN(coment=None,et=None):
  return STAN("IN",None,None,et,coment)

def FIN(coment=None,et=None):
  return STAN("FIN",None,None,et,coment)

def CIN(coment=None,et=None):
  return STAN("CIN",None,None,et,coment)

def OUT(coment=None,et=None):
  return STAN("OUT",None,None,et,coment)

def FOUT(coment=None,et=None):
  return STAN("FOUT",None,None,et,coment)

def COUT(coment=None,et=None):
  return STAN("COUT",None,None,et,coment)

def JMP(dest,coment=None,et=None):
  return STAN("JMP",dest,None,et,coment)

def BRZ(dest,coment=None,et=None):
  return STAN("BRZ",dest,None,et,coment)

def BRD(dest,coment=None,et=None):
  return STAN("BRD",dest,None,et,coment)

def BRP(dest,coment=None,et=None):
  return STAN("BRP",dest,None,et,coment)

def BRN(dest,coment=None,et=None):
  return STAN("BRN",dest,None,et,coment)

def HALT(coment=None,et=None):
  return STAN("HALT",None,None,et,coment)

def CALL(dest,coment=None,et=None):
  return STAN("CALL",dest,None,et,coment)

def RET(coment=None,et=None):
  return STAN("RET",None,None,et,coment)
